#include<iostream>
#include<cstring>
using namespace std;
class VirPhone
{
    private:
        string PhoneNumber,UserName;
        char type;
        int statu;
    public:
        VirPhone(string _pn,char _ty,int _st,string _un):PhoneNumber(_pn),UserName(_un),type(_ty),statu(_st)
        {
            cout<<PhoneNumber<<" constructed."<<endl;
        }
        ~VirPhone()
        {
            cout<<PhoneNumber<<" destructed."<<endl;
        }
        void ClPrint()
        {
            cout<<"Phone="<<PhoneNumber<<"--Type="<<type<<"--State=";
            if(statu==1)
                cout<<"use--Owner=";
            else
                cout<<"unuse--Owner=";
            cout<<UserName<<endl;
        }
        string getPhone()
        {
            return PhoneNumber;
        }
        VirPhone(){}

};
void Check(VirPhone** arr,string checkPhone)
{
    for(int i=0;i<3;i++)
    {
        if(arr[i]->getPhone()==checkPhone)
        {
            arr[i]->ClPrint();
            return;
        }
    }
    cout<<"wrong number."<<endl;
}
int main()
{
    VirPhone* arr[3];
    for(int i=0;i<3;i++)
    {
        string _num,_na;
        char _ty;
        int st;
        cin>>_num>>_ty>>st>>_na;
        arr[i]=new VirPhone(_num,_ty,st,_na);
    }
    int t;
    cin>>t;
    while(t--)
    {
        string che;
        cin>>che;
        Check(arr,che);
    }
    for(int i=2;i>=0;--i)
    {
        delete arr[i];
    }
}